<template>
  <div>
    <!-- 品名列表 -->
    <div class="table-default">
      {{ props.CategoryList }}
      <br />
      {{ categroyArr }}
      <el-table :data="props.CategoryList" class="mt-3" v-loading="loading">
        <el-table-column prop="id" label="ID" />
        <!-- <el-table-column prop="fseq" label="行号" /> -->
        <el-table-column prop="fseqname" label="品号名称" />
        <el-table-column prop="number" label="箱号" min-width="200">
          <template #default="scope">
            <span class="required">*</span>
            <el-input-number v-model="props.CategoryList[scope.$index].number" :min="1" @change="numberChange" required />
          </template>
        </el-table-column>
        <el-table-column prop="supplier_id" label="供应商ID" />
        <el-table-column prop="creator_id" label="创建者" />
        <el-table-column prop="created_at" label="创建时间" />
        <el-table-column prop="updated_at" label="更新时间" />
      </el-table>

      <Paginate />
    </div>

    <!-- <Dialog v-model="visible" :title="title" destroy-on-close>
        <Create @close="close(reset)" :primary="id" :api="api" />
      </Dialog> -->
  </div>
</template>
  
  <script lang="ts" setup>
import { computed, onMounted } from 'vue'
// import Create from './create.vue'
import { useGetList } from '/admin/composables/curd/useGetList'
import { useDestroy } from '/admin/composables/curd/useDestroy'
import { useOpen } from '/admin/composables/curd/useOpen'

const props = defineProps({
  supplierId: String | Number,
  CategoryList: Array,
})

let emit = defineEmits(['sendData'])

let categroyArr = computed(() => {
  return props.CategoryList
})

const numberChange = val => {
  console.log(val)
  console.log(11111, categroyArr.value)
  let arr = []
//   categroyArr.value.SuppliernamedeliveryAll = []
  for (let i = 0; i < categroyArr.value.length; i++) {
    let obj = { suppliernamedelivery_id: '', number: '' }
    obj.suppliernamedelivery_id = categroyArr.value[i].id
    obj.number = categroyArr.value[i].number
    arr[i] = obj
  }
  console.log(arr);

}

//   需要拼接id
// const api = `purchasing/categoryApi/${props.supplierId}`

// const { data, query, search, reset, loading } = useGetList(api)
const { destroy, deleted } = useDestroy()
const { open, close, title, visible, id } = useOpen()

// const tableData = computed(() => data.value?.data)

onMounted(() => {
  //   search()
  //   deleted(reset)
})
</script>
  